<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

use Carbon\Carbon;

use App\Service\Model\Orders;
use App\Service\Model\OrderDetails;

/**
 * 删除过期且未确认的订单定时任务
 */
class DeleteOrders extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'order:delete';
    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = ' ';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        Orders::where('status',Orders::status_init)->where('created_at','<',Carbon::yesterday())->delete();
        OrderDetails::where('status',Orders::status_init)->where('created_at','<',Carbon::yesterday())->delete();

    }
    
}
